package com.shadow.study.jpa.repository;

import com.shadow.study.jpa.entity.JPARoleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface JPARoleRepository extends JpaRepository<JPARoleEntity, String> {

    JPARoleEntity findByName(String name);

    @Query("select e from JPARoleEntity e where e.code like concat('%', :code, '%')")
    List<JPARoleEntity> findByCodeLike(@Param("code") String code);

    List<JPARoleEntity> findRoleEntitiesByName(String name);
}
